package com.jcrj.util;

import java.io.File;
import java.io.InputStream;
import java.util.List;
import org.apache.tools.zip.ZipEntry;
import org.apache.tools.zip.ZipOutputStream;

public class FileUtil
{
  public static void zipFile(List files, List<String> fileName, ZipOutputStream outputStream)
  {
    int size = files.size();
    for (int i = 0; i < size; i++) {
      File file = (File)files.get(i);
      String name = (String)fileName.get(i);
      zipFileAll(file, name, outputStream);
    }
  }

  public static void zipFileAll(File inputFile, String fileName, ZipOutputStream ouputStream)
  {
    FtpUploadUtil load = new FtpUploadUtil();
    try
    {
      ouputStream.setEncoding("GBK");
      InputStream in = load.downLoadMailFile(inputFile.getPath());
      ZipEntry entry = new ZipEntry(fileName);
      ouputStream.putNextEntry(entry);

      byte[] buffer = new byte[1024];
      int nNumber;
      while ((nNumber = in.read(buffer)) != -1)
      {
//        int nNumber;
        ouputStream.write(buffer, 0, nNumber);
      }

      ouputStream.flush();
      in.close();
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
  }
}

/* Location:           /Volumes/work/oa/WEB-INF/classes/
 * Qualified Name:     com.jcrj.util.FileUtil
 * JD-Core Version:    0.6.0
 */